package cn.swing.learning;

import javax.swing.*;
import java.awt.*;

/**
 * Desc : TODO
 * ClassName : cn.swing.learning.IdeaFrame2
 *
 * @author : 林鹏群
 * @date : 2022/12/20 9:37
 */
public class MineFrame extends JFrame {
    private MineState mineState;
    private MineField mineField;
    private MineMenuBar mineMenuBar;


    public MineFrame() {
        //设置标题
        this.setTitle("张三 学号");
        //设置初始化位置
        this.setLocation(500, 500);
        //设置关闭事件 EXIT_ON_CLOSE
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        //设置图标
        this.setIconImage(new ImageIcon("./picture/icon.gif").getImage());
        //设置布局
        this.setLayout(new BorderLayout());
        //初始化菜单栏
        mineMenuBar = new MineMenuBar(this);
        //添加菜单栏
        this.setJMenuBar(mineMenuBar);
        //初始化状态栏
        mineState = new MineState(this);
        //添加状态栏
        this.add(mineState,BorderLayout.NORTH);
        //初始化雷区
        mineField = new MineField(this);
        //添加雷区
        this.add(mineField);
        //设置大小适应
        this.pack();
        //设置关闭改变大小
        //设置窗体可见
        this.setVisible(true);
    }


    public void restart(){
        this.remove(mineState);
        this.remove(mineField);
        //初始化状态栏
        mineState = new MineState(this);
        //添加状态栏
        this.add(mineState,BorderLayout.NORTH);
        //初始化雷区
        mineField = new MineField(this);
        //添加雷区
        this.add(mineField);
        //设置大小适应
        this.pack();
    }




    public static void main(String[] args) {
        new MineFrame();
    }

    public MineState getMineState() {
        return mineState;
    }

    public MineField getMineField() {
        return mineField;
    }

    public MineMenuBar getMineMenuBar() {
        return mineMenuBar;
    }
}
